//
//  CaseTableViewCell4.m
//  LiangYa_BObject
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 YuHao. All rights reserved.
//

#import "CaseTableViewCell4.h"
#import "CaseCollectionViewCell1.h"
#import "CaseCollectionViewCell2.h"
@implementation CaseTableViewCell4

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.imagesArr1 = [NSMutableArray array];
        
        self.mylabel= [[NightLabel alloc] init];
        [self.contentView addSubview:self.mylabel];
        

        
        self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
        //        _flowLayout.itemSize = CGSizeMake(100*_a, 100*_a);
        //        _flowLayout.sectionInset = UIEdgeInsetsMake(15*_a, 15*_a, 15*_a, 15*_a);
        
        self.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 114, self.contentView.bounds.size.width, self.contentView.bounds.size.height - 114) collectionViewLayout:_flowLayout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.backgroundColor = [UIColor clearColor];
        _collectionView.showsHorizontalScrollIndicator = NO;
        [self.contentView addSubview:_collectionView];
        
        
        [_collectionView registerClass:[CaseCollectionViewCell1 class] forCellWithReuseIdentifier:@"DetailDate111"];
        
        
        
        
        
    }
    return self;
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
   

    return _imagesArr1.count;
    
    
}

- (void)setImagesArr1:(NSMutableArray *)imagesArr1

{
    if (_imagesArr1 != imagesArr1) {
        _imagesArr1 = imagesArr1;
        
        [self.collectionView reloadData];
    }
}




- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

    [self.deledate passValue:_imagesArr1 numer:indexPath.row];
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    CaseCollectionViewCell1 *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DetailDate111" forIndexPath:indexPath];
    NSString *str = [[_imagesArr1 objectAtIndex:indexPath.row] objectForKey:@"img_315"] ;
    NSString *str1 = [[_imagesArr1 objectAtIndex:indexPath.row] objectForKey:@"brand_name"];
    NSString *str2 = [[_imagesArr1 objectAtIndex:indexPath.row] objectForKey:@"cat_name"];
    NSString *str3 = [NSString stringWithFormat:@"[%@]%@",str1,str2];
    cell.mylabel1.text = str3;

    [cell.myimageview sd_setImageWithURL:[NSURL URLWithString:str]placeholderImage:[UIImage imageNamed:@"baikejiaju.png"]];
    return cell;
    
    
    
}






- (void) layoutSubviews
{
    [super layoutSubviews];
     self.backgroundColor = [UIColor clearColor];
    self.mylabel.frame = CGRectMake(10, 5, 100, 25);
    _flowLayout.itemSize = CGSizeMake(100, 100);
    _flowLayout.sectionInset = UIEdgeInsetsMake(0, 5, 0, 10);
    
    _collectionView.frame = CGRectMake(0 , 30, cellWidth, cellHeight - 30);
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
